#!/bin/sh

set -e

PATH_TO_SDCV="$1"
TESTS_DIR="$2"

mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
cp -R "${TESTS_DIR}/stardict-test_dict-2.4.2" "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic
unset SDCV_PAGER
RES=`"$PATH_TO_SDCV" -n -u test_dict test | grep "test passed"`

if [ -z "$RES" ]; then
	echo "we didn't find in stardict-test_dict-2.4.2 "test" keyword, something wrong" >&2
	exit 1
fi

rm -fr "${XDG_DATA_HOME:-$HOME/.local/share}"/stardict/dic/stardict-test_dict-2.4.2

exit 0
